package org.rasterfun.language2

import bool.Bool

/**
 * 
 * 
 * @author Hans Haggstrom
 */
class IfExpression[T <: Expression](e: Bool, trueValue: T, falseValue: T) extends Expression {

	override def kind = trueValue.kind commonType falseValue.kind

  override def children = List(e, trueValue, falseValue)
  
  def generateCode(context: Context, s: StringBuilder) {
    s.append(" ( ( ")
    e.code(context, s)
    s.append(" ) ? ( ")
    trueValue.code(context, s)
    s.append(" ) : ( ")
    falseValue.code(context, s)
    s.append(" ) ) ")
  }
  
}

